﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SilverlightHVP.ViewModel;
using SilverlightHVP.View;

namespace SilverlightHVP
{
    public partial class MainPage : UserControl
    {

        private Viewer viewer;
        private System.Guid firstSetGuid = System.Guid.NewGuid();
        private State state;


        public MainPage()
        {
            InitializeComponent();
            state = new State(0);
            Loaded += new RoutedEventHandler(MainPage_Loaded);

            Application.Current.Host.Content.FullScreenChanged += new System.EventHandler(Content_FullScreenChanged);
        }

        void Content_FullScreenChanged(object sender, System.EventArgs e)
        {
            if (Application.Current.Host.Content.IsFullScreen)
            {
                MyBackground.MaxWidth = double.PositiveInfinity;
                MyBackground.MaxHeight = double.PositiveInfinity;
            }
            else
            {
                MyBackground.MaxWidth = 1200;
                MyBackground.MaxHeight = 900;
            }
        }

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            this.viewer = new SilverlightHVP.View.Viewer();
            this.ViewerFrame.Content = this.viewer;

            var itemsView = new ItemsView();
            var linksView = new LinksView();
            var topicsView = new TopicsView();
            var noteTakerView = new NoteTakerView();
            this.ItemsListFrame.Content = itemsView;
            this.TopicsFrame.Content = topicsView;
            this.linksListFrame.Content = linksView;
            this.NoteTakerFrame.Content = noteTakerView;
            itemsView.SetViewModel(new ItemsViewModel(state));
            topicsView.SetViewModel(new TopicsViewModel(state));
            linksView.SetViewModel(new LinksViewModel(state));
            noteTakerView.SetViewModel(new NoteTakerViewModel(state));

            var framer = viewer.SetViewModel(new ViewerViewModel(state));
            var player = framer.SetViewModel(new FramerViewModel(state));
            player.SetViewModel(new PlayerViewModel(state));

        }

    }
}
